package www.com.springboot_20200312.rabbitmqDemo.FanoutExchange.consumer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import www.com.springboot_20200312.rabbitmqDemo.FanoutExchange.message.DemoFanoutMessage;

/**
 * @program: springboot_20200312
 * @ClassName consumer
 * @description:
 * @author: jht
 * @create: 2021-12-07 10:28
 * @Version 1.0
 **/
@Component
@RabbitListener(queues = DemoFanoutMessage.QUEUE_A)
class Demo03ConsumerA {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @RabbitHandler
    public void onMessage(DemoFanoutMessage message) {
        logger.info("[onMessage][线程编号:{} 消息内容：{}]", Thread.currentThread().getId(), message);
    }

}

// Demo03ConsumerB.java
@Component
@RabbitListener(queues = DemoFanoutMessage.QUEUE_B)
class Demo03ConsumerB {
    private Logger logger = LoggerFactory.getLogger(getClass());

    @RabbitHandler
    public void onMessage(DemoFanoutMessage message) {
        logger.info("[onMessage][线程编号:{} 消息内容：{}]", Thread.currentThread().getId(), message);
    }

}
